//
//  PayFoodStepTableViewCell.m
//  Menu
//
//  Created by dllo on 15/7/7.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "PayFoodStepTableViewCell.h"

@implementation PayFoodStepTableViewCell

- (void)dealloc
{
    [_stepImgView release];
    [_stepLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.stepLabel = [[UILabel alloc] initWithFrame:CGRectMake(30*WIDTH, 10*HEIGHT, 315*WIDTH, 30*HEIGHT)];
    self.stepLabel.backgroundColor = [UIColor whiteColor];
    self.stepLabel.numberOfLines = 0;
    self.stepLabel.font = [UIFont systemFontOfSize:17];
    [self.contentView addSubview:self.stepLabel];
    [_stepLabel release];
    
    self.stepImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.stepLabel.frame.origin.x, self.stepLabel.frame.origin.y + self.stepLabel.frame.size.height, self.stepLabel.frame.size.width, 200*HEIGHT)];
    [self.contentView addSubview:self.stepImgView];
    [_stepImgView release];
}

-(void)setPayFoodModel:(PayFoodModel *)payFoodModel
{
    if (_payFoodModel != payFoodModel)
    {
        [_payFoodModel release];
        _payFoodModel = [payFoodModel retain];
    }
    self.stepLabel.text = [NSString stringWithFormat:@"%@ . %@",payFoodModel.orderid,payFoodModel.describe];
    [self.stepImgView sd_setImageWithURL:[NSURL URLWithString:payFoodModel.imageProcess]];
    
    CGFloat LabelHeight = [[self class] heightForLabel:self.stepLabel.text Width:self.stepLabel.frame.size.width Height:1000*HEIGHT Font:17];
    CGRect LabelFrame = self.stepLabel.frame;
    LabelFrame.size.height = LabelHeight;
    self.stepLabel.frame = LabelFrame;
    
    self.stepImgView.frame = CGRectMake(30*WIDTH, 10*HEIGHT+payFoodModel.height, 315*WIDTH, 200*HEIGHT);
}

+(CGFloat)heightForLabel:(NSString *)text Width:(CGFloat)width Height:(CGFloat)height Font:(CGFloat)font
{
    CGSize size = CGSizeMake(width, height);
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObject:[UIFont systemFontOfSize:font] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return frame.size.height;
}































- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
